package com.example.touristassist;

import java.util.HashMap;

public class DBMetadata {
	public static final String Name = "StockPortfolio.db";
	public static final int Version = 1;
	private HashMap<String,TableMetadata> tables = new HashMap<String,TableMetadata>();
	
	public HashMap<String,TableMetadata> getTables() { return tables; }
	public void setTables(HashMap<String,TableMetadata> tables) { this.tables = tables; }
	
	static {
		
	}
	
	public DBMetadata() {
		CreateTableAppointment();
		CreateTableChat();
	}
	
	public void CreateTableAppointment() {
		ColumnMetadata[] columns = new ColumnMetadata[] {
			new ColumnMetadata("_id", "integer", "primary key autoincrement"),
			new ColumnMetadata("name", "text", "not null"),
			new ColumnMetadata("final_time", "datetime", ""),
			new ColumnMetadata("latitude", "double", ""),
			new ColumnMetadata("longitude", "double", "")
		};
			
		TableMetadata table = new TableMetadata("stocks", columns);
		table.Name = "appointment";
		
		this.tables.put(table.Name, table);
	}
	
	public void CreateTableChat() {
		ColumnMetadata[] columns = new ColumnMetadata[] {
				new ColumnMetadata("_id", "integer", "primary key autoincrement"),
				new ColumnMetadata("from_name", "text", ""),
				new ColumnMetadata("to_name", "text", ""),
				new ColumnMetadata("chat_time", "datetime", ""),
				new ColumnMetadata("message", "text", ""),
			};
				
			TableMetadata table = new TableMetadata("stocks", columns);
			table.Name = "chat";
			
			this.tables.put(table.Name, table);
	}
	
	public class TableMetadata {
		public String Name = "";
		public ColumnMetadata[] Columns = new ColumnMetadata[]{ };
		
		public TableMetadata() { }
		public TableMetadata(String name, ColumnMetadata[] columns) {
			this.Name = name;
			this.Columns = columns;
		}
	}
	
	public class ColumnMetadata {
		public String Name = "";
		public String Type = "";
		public String Arguments = "";
		
		public ColumnMetadata() { }
		public ColumnMetadata(String name, String type, String arguments) {
			this.Name = name;
			this.Type = type;
			this.Arguments = arguments;
		}
	}
}
